#include<string>
#include<vector>
#include<iostream>
#include<math.h>
using namespace std;

int findMaxForm(vector<string>& strs, int n, int m) {
    int len = strs.size();
    vector<vector<vector<int>>> dp(len + 1, vector<vector<int>>(m + 1, vector<int>(n + 1)));
    for (int i = 1; i <= len; i++)
    {
        int s = strs[i - 1].size();
        int a = 0, b = 0;
        for (int j = 0; j < s; j++)
        {
            if (strs[i - 1][j] == '1') a++;
            else b++;
        }
        for (int j = 0; j <= m; j++)
        {
            for (int k = 0; k <= n; k++)
            {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j >= a && k >= b) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - a][k - b] + 1);
            }
        }
    }
    return dp[len][m][n];
}

int profitableSchemes(int n, int minProfit, vector<int>& group, vector<int>& profit) {
    int m = group.size(), p = profit.size();

    vector<vector<vector<int>>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(p + 1)));
    for (int j = 0; j <= n; j++) dp[0][j][0] = 1;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= p; k++)
            {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j >= group[i - 1])
                    dp[i][j][k] += dp[i - 1][j - group[i - 1]][max(0, k - profit[i - 1])];
                dp[i][j][k] = dp[i][j][k] % (int)(pow(10, 9) + 7);
            }
        }
    }
    return dp[m][n][p];
}

int main()
{
	vector<string> v{ "10","0001","111001","1","0" };
	//cout << v[0].size() << v[0][1];
    findMaxForm(v, 5, 3);

	return 0;
}